package day02;

/*
 * Author: JacksonCoder
 * FileName: demo1
 * Version: 1.0.0
 * Date: 2025/3/31
 */

public class demo1AutoBoxingAndUnboxing {

    public static void main(String[] args) {
        // 自动装箱：基本类型自动转换为包装类对象
        Integer num1 = 10;  // 相当于 Integer.valueOf(10)

        // 自动拆箱：包装类对象自动转换为基本类型
        int num2 = num1;    // 相当于 num1.intValue()
        System.out.println("num1 = " + num1);
        System.out.println("num2 = " + num2);

        int n = 20;
        Integer n1 = n;
        System.out.println("n = " + n);
        System.out.println("n1 = " + n1);

        Integer n2 = Integer.valueOf(30);
        int n3 = n2.intValue();
        System.out.println("n2 = " + n2);
        System.out.println("n3 = " + n3);


    }

}
